package com.baseweb.webadmin.core.model.mapper;

import com.baseweb.webadmin.core.model.Sql.SqlProvider;
import com.baseweb.webadmin.core.model.pojo.ByUserMessage;
import com.baseweb.webadmin.core.util.RequestPage;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by zx on 2017/9/2.
 */
public interface ByUserMessageMapper {

    @Insert({
            "insert into by_user_message (order_id,user_id, content, create_time)",
            "values (#{orderId,jdbcType=INTEGER},#{userId,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR},  ",
            " #{createTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    Integer insert(ByUserMessage record);

    @SelectProvider(type = SqlProvider.class,method = "selectByUserMessageListByPage")
    @ResultMap("BaseResultMap")
    List<ByUserMessage> selectByUserMessageListByPage(@Param("userId")Integer userId, @Param("page")RequestPage page);

    @SelectProvider(type = SqlProvider.class,method = "countByUserMessageListByPage")
    Integer countByUserMessageListByPage(@Param("userId")Integer userId, @Param("page")RequestPage page);

    @Delete({
            "delete from by_user_message",
            "where id = #{id,jdbcType=INTEGER}"
    })
    Integer deleteByPrimaryKey(Integer id);
}
